﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ERP管理系统</title>
    <link href="~/Content/images/Default.css" rel="stylesheet" />
    <link href="~/Content/images/User_Login.css" rel="stylesheet" />
    <link href="~/Content/images/xtree.css" rel="stylesheet" />
    @*引用Jquery文件的JS脚本*@
    <script src="~/Scripts/jquery-1.7.1.js"></script>
    <script type="text/javascript">
        //当用户刷新页面触发的方法
        $(function () {
            //实现用户登录的方法
            LoginUserInfo();
            //单击的时候修改验证码的方法
            ClickRemoveChangeCode();
            //按回车键提交
            document.onkeydown = function (evt) {
                var evt = window.event ? window.event : evt;
                if (evt.keyCode == 13) {
                    $("#btnLogin").trigger("click");
                    return false;
                }
            }
        });

        //实现用户登录
        function LoginUserInfo() {
            //获取单击用户登录按钮的事件
            $("#btnLogin").click(function () {
                //首先获取到要传递到控制器的参数，并且构造成Json。LoginName，Password，Code
                var postData = {
                    LoginName: $("#LoginName").val(),
                    LoginPwd: $("#LoginPwd").val(),
                    Code: $("#Code").val()
                };
                if ($("#LoginName").val() == "" || $("#LoginPwd").val() == "" || $("#Code").val() == "") {
                    alert("用户名密码和验证不能为空！");
                    return false;
                }
                $.ajax({
                    type: "post",
                    url: "/Login/CheckUserInfo",
                    data: postData,
                    async: false,
                    success: function (data) {
                        if (data == "OK") {
                            window.location.href = "/Home/Index";

                        } else {
                            alert(data);
                            window.location.href = "/Login/Index";
                        }
                    }
                });
            });
        }

        //单击重新改变验证码
        function ClickRemoveChangeCode() {
            //首先我们获取到验证码的路径
            var code = $("#imgCode").attr("src");
            //然后重新给验证码的路径赋值
            $("#imgCode").attr("src", code + "1");
        }
    </script>
</head>
<body id="userlogin_body">
    <div id="user_login">
        <dl>
            <dd id="user_top">
                <ul>
                    <li class="user_top_l"></li>
                    <li class="user_top_c"></li>
                    <li class="user_top_r"></li>
                </ul>
                <dd id="user_main">
                    <ul>
                        <li class="user_main_l"></li>
                        <li class="user_main_c">
                            <div class="user_main_box">
                                <ul>
                                    <li class="user_main_text">用户名： </li>
                                    <li class="user_main_input">
                                        <input type="text" class="TxtUserNameCssClass" id="LoginName" name="LoginName">
                                    </li>
                                </ul>
                                <ul>
                                    <li class="user_main_text">密  码： </li>
                                    <li class="user_main_input">
                                        <input type="password" class="TxtPasswordCssClass" id="LoginPwd" name="LoginPwd">
                                    </li>
                                </ul>
                                <ul>
                                    <li class="user_main_text">验证码： </li>
                                    <li class="user_main_input">
                                        <input type="text" class="TxtPasswordCssClass" id="Code" name="Code">
                                    </li>
                                </ul>
                                <ul>
                                    <li class="user_main_text">验证码： </li>
                                    <li class="user_main_input">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <img src="/Login/CheckCode?ID=1" id="imgCode" alt="单击可刷新" onclick="ClickRemoveChangeCode()" />
                                        &nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" onclick="ClickRemoveChangeCode();return false;">看不清,换一张</a>
                                    </li>
                                </ul>
                            </div>
                        </li>
                        <li class="user_main_r">
                            <input type="image" class="IbtnEnterCssClass" id="btnLogin" name="btnLogin" src="~/Content/images/user_botton.gif">
                        </li>
                    </ul>
                    <dd id="user_bottom">
                        <ul>
                            <li class="user_bottom_l"></li>
                            <li class="user_bottom_c"><span style="MARGIN-TOP: 40px"></span></li>
                            <li class="user_bottom_r"></li>
                        </ul>
                    </dd>
        </dl>
    </div>
</body>
</html>
